package com.sxu.greedy.day3;

/**
 * 最优除法
 */
public class Test15 {
    public String optimalDivision(int[] nums) {
        int n = nums.length;
        StringBuffer ret = new StringBuffer();
        if(n == 1)
            return ret.append(nums[0]).toString();
        if(n == 2)
            return ret.append(nums[0]).append("/").append(nums[1]).toString();
        ret.append(nums[0]).append("/(").append(nums[1]);
        for(int i = 2; i < n; i++){
            ret.append("/").append(nums[i]);
        }
        ret.append(")");
        return ret.toString();
    }
}
